// ES6 class 继承
// class关键字是对ES5 function自定义构造函数的封装

// 父类
class People {
  // 构造函数，一个class只能有一个constructor
  constructor(name, age) {
    console.log('People constructor');
    this.name = name;
    this.age = age;
  }

  say() {
    console.log('hello');
  }

  // 静态函数不能通过对象调用,通过类调用People.see/Child.see
  static see() {
    console.log('how are you');
  }
}
// 子类
class Child extends People {
  constructor(name, age) {
    console.log('Child constructor');
    super(name, age); // 执行父类构造函数
  }

  goodbye() {
    console.log('goodbye');
  }
}

var child = new Child('zhangsan', 20);
console.log(child);
child.say(); //hello
child.see(); //Error：静态函数不能被继承
child.goodbye(); //goodbye
console.log(child instanceof Child); //true
console.log(child instanceof People); //true
console.log(child instanceof Object); //true
console.log(child.__proto__==Child.prototype); //true
console.log(Child.prototype.__proto__==People.prototype); //true
console.log(Child.__proto__==Function.prototype);  //false



